<template>
    <section>
        <el-card shadow="never">
            <el-form @submit.native.prevent="submit" :model="form">
                <el-input type="textarea" v-model="form.content" placeholder="请发布今天的沙雕图"></el-input>
                <el-button native-type='submit'>发布</el-button>
            </el-form>
        </el-card>
    </section>
</template>

<script>
export default {
  data() {
    return {
      form: {
        content: ""
      }
    };
  },
  methods: {
    submit() {
      let Posts = this.$AV.Object.extend("Posts");
      let post = new Posts();
      post.set("content", this.form.content);
      post.set("user_id", this.$AV.User.current().id);
      post.set("priority", 1);
      post.save().then(
        function(todo) {
          this.form.content = "";
          // console.log("objectId is " + todo.id);
        },
        function(error) {
          // console.error(error);
        }
      );
    }
  }
};
</script>

<style scoped>
</style>
